package com.crl.rcdp.gateway.config;

import com.crl.rcdp.gateway.filter.ErrorFilter;
import com.crl.rcdp.gateway.filter.PreRequestLogFilter;
import com.crl.rcdp.gateway.filter.TimeCostPostFilter;
import com.crl.rcdp.gateway.filter.TimeCostPreFilter;
import com.crl.rcdp.gateway.filter.TokenFilter;
import com.netflix.zuul.ZuulFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: 孔垂云
 * @version: 1.0
 * @date: 2020/7/12 18:00
 */
@Configuration
public class GatewayConfig {

    /**
     * 校验权限filter
     *
     * @return
     */
    @Bean
    public TokenFilter tokenFilter() {
        return new TokenFilter();
    }

    /**
     * 全局异常处理filter
     *
     * @return
     */
    @Bean
    public ErrorFilter errorFilter() {
        return new ErrorFilter();
    }

    @Bean
    public PreRequestLogFilter preRequestLogFilter(){
        return new PreRequestLogFilter();
    }
    /**
     * 记录请求参数和返回值
     * @return
     */
  /*  @Bean
    public RecordGlobalFilter recordGlobalFilter() {
        return new RecordGlobalFilter();
    }*/
    @Bean
    public ZuulFilter timeCostPreFilter() {
        return new TimeCostPreFilter();
    }

    @Bean
    public ZuulFilter timeCostPostFilter() {
        return new TimeCostPostFilter();
    }




//    @Bean
//    public AuthFilter authFilter() {
//        return new AuthFilter();
//    }



    /*
     *//**
     * 记录日志
     *
     * @return
     *//*
    @Bean
    public ExceptionLogFilter exceptionLogFilter() {
        return new ExceptionLogFilter();
    }

    *//**
     * 请求过慢或返回非200
     *
     * @return
     *//*
    @Bean
    public LogFilter logFilter() {
        return new LogFilter();
    }
*/

//    @Bean
//    public RequestRecordFilter logFilter() {
//        return new RequestRecordFilter();
//    }
}
